package antrace;

import processing.core.PMIDlet;

public class IngameMenuOverlay extends Overlay {
	
	public IngameMenuOverlay(){
		super(AntRace.midlet.loadImage("/images/gui/rutaGameoverMeny.png"));
		
		texts = new OverlayText[3];
		texts[0] = new OverlayText("Continue", 60, 200);
		texts[1] = new OverlayText("New game", 55, 230);
		texts[2] = new OverlayText("Quit to menu", 40, 260);
		
		this.updateSelects();
	}
	
	public void keyPressed(int keyCode){
		switch(keyCode){
		case PMIDlet.FIRE:
			switch(selectedIndex){
			case 0:
				this.toggleVisible();
				break;
			case 1:
				AntRace.game.resetGame();
				this.toggleVisible();
				break;
			case 2:
				AntRace.game.resetGame();
				selectedIndex = 0;
				this.toggleVisible();
				AntRace.viewManager.currentView = AntRace.menu;
			}
			break;
		case PMIDlet.UP:
			if(selectedIndex == 0)
				selectedIndex = 2;
			else
				selectedIndex--;
			break;
		case PMIDlet.DOWN:
			if(selectedIndex == 2)
				selectedIndex = 0;
			else
				selectedIndex++;
			break;
		}
		this.updateSelects();
	}
	
}
